﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CommonLibrary.Common
{
    public class WorkflowFileWrapper
    {
        public static void String2File(string markup,string rules,string layout)
        {
            string xomlpath = @"test.xoml";
            string rulespath = @"test.rules";
            string layoutpath = @"test.layout";
            try
            {
                using (FileStream xomlfs = new FileStream(xomlpath, FileMode.Create))
                using (FileStream rulesfs = new FileStream(rulespath, FileMode.Create))
                using (FileStream layoutfs = new FileStream(layoutpath, FileMode.Create))
                {
                    if (!string.IsNullOrEmpty(markup))
                    {
                        byte[] xomldata = new UTF8Encoding().GetBytes(markup);
                        xomlfs.Write(xomldata, 0, xomldata.Length);
                    }
                    if (!string.IsNullOrEmpty(rules))
                    {
                        byte[] rulesdata = new UTF8Encoding().GetBytes(rules);
                        xomlfs.Write(rulesdata, 0, rulesdata.Length);
                    }
                    if (!string.IsNullOrEmpty(layout))
                    {
                        byte[] layoutdata = new UTF8Encoding().GetBytes(layout);
                        xomlfs.Write(layoutdata, 0, layoutdata.Length);
                    }
                }
            }
            catch (Exception e)
            {
                
                throw;
            }
        }

    }
}
